using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using SBPweb.Themes.Windows;
using SBPweb.Themes.Windows.Skins;

namespace SBPweb.Controls.Windows.Common
{
	/// <summary>
	/// Class of MessageBox
	/// </summary>
	public partial class MessageBox
	{
		#region Static properties

		private static Dictionary<MsgBoxButtons, string> mButtonTexts;

		public static Dictionary<MsgBoxButtons, string> ButtonTexts
		{
			set
			{
				mButtonTexts = value;
			}
			get
			{
				return mButtonTexts;
			}
		}

		#endregion
		
		static MessageBox()
		{
			Dictionary<MsgBoxButtons, string> msgBoxTexts = new Dictionary<MsgBoxButtons, string>();
			msgBoxTexts.Add(MsgBoxButtons.OK, string.Empty);
			msgBoxTexts.Add(MsgBoxButtons.Yes, string.Empty);
			msgBoxTexts.Add(MsgBoxButtons.Retry, string.Empty);
			msgBoxTexts.Add(MsgBoxButtons.Ignore, string.Empty);
			msgBoxTexts.Add(MsgBoxButtons.Abort, string.Empty);
			msgBoxTexts.Add(MsgBoxButtons.No, string.Empty);
			msgBoxTexts.Add(MsgBoxButtons.Cancel, string.Empty);
			ButtonTexts = msgBoxTexts;
		}


		#region MessageBox.Show methods

		public static DialogResult Show(string text)
		{
			return Show((IWin32Window)null, text);
		}

		public static DialogResult Show(string text, string caption)
		{
			return Show((IWin32Window)null, text, caption);
		}

		public static DialogResult Show(string text, string caption, MessageBoxButtons buttons)
		{
			return Show((IWin32Window)null, text, caption, buttons);
		}

		public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
		{
			return Show((IWin32Window)null, text, caption, buttons, icon);
		}

		public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
		{
			return Show((IWin32Window)null, text, caption, buttons, icon, defaultButton);
		}

		public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
		{
			return Show((IWin32Window)null, text, caption, buttons, icon, defaultButton, options);
		}

		public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, bool displayHelpButton)
		{
			// displayHelpButton ?
			return Show((IWin32Window)null, text, caption, buttons, icon, defaultButton, options/*, displayHelpButton*/);
		}

		public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath)
		{
			return Show((IWin32Window)null, text, caption, buttons, icon, defaultButton, options, helpFilePath);
		}

		public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator helpNavigator)
		{
			return Show((IWin32Window)null, text, caption, buttons, icon, defaultButton, options, helpFilePath, helpNavigator);
		}

		public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, string keyWord)
		{
			return Show((IWin32Window)null, text, caption, buttons, icon, defaultButton, options, helpFilePath, keyWord);
		}

		public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator helpNavigator, object param)
		{
			return Show((IWin32Window)null, text, caption, buttons, icon, defaultButton, options, helpFilePath, helpNavigator, param);
		}






		public static DialogResult Show(IWin32Window owner, string text)
		{
			string caption = string.Empty;
			return Show(owner, text, caption);
		}

		public static DialogResult Show(IWin32Window owner, string text, string caption)
		{
			MessageBoxButtons buttons = MessageBoxButtons.OK;
			return Show(owner, text, caption, buttons);
		}

		public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons)
		{
			MessageBoxIcon icon = MessageBoxIcon.None;
			return Show(owner, text, caption, buttons, icon);
		}

		public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
		{

			MessageBoxDefaultButton defaultButton = MessageBoxDefaultButton.Button1;
			return Show(owner, text, caption, buttons, icon, defaultButton);
		}

		public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton)
		{
			MessageBoxOptions options = MessageBoxOptions.DefaultDesktopOnly;
			return Show(owner, text, caption, buttons, icon, defaultButton, options);
		}

		public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options)
		{
			string helpFilePath = string.Empty;
			return Show(owner, text, caption, buttons, icon, defaultButton, options, helpFilePath);
		}

		public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath)
		{
			HelpNavigator helpNavigator = HelpNavigator.AssociateIndex;
			return Show(owner, text, caption, buttons, icon, defaultButton, options, helpFilePath, helpNavigator);
		}

		public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator helpNavigator)
		{
			return Show(owner, text, caption, buttons, icon, defaultButton, options, helpFilePath, helpNavigator, null);
	    }

		public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, string keyWord)
		{
			HelpNavigator helpNavigator = HelpNavigator.AssociateIndex;
			return Show(owner, text, caption, buttons, icon, defaultButton, options, helpFilePath, helpNavigator, keyWord);
		}

		public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defaultButton, MessageBoxOptions options, string helpFilePath, HelpNavigator helpNavigator, object param)
		{
			MessageBoxForm form = new MessageBoxForm(ButtonTexts);

			if (owner is Form && owner != null && !(form.UseDefaultSkin = (owner as Form).UseDefaultSkin))
			{
				form.Skin = (owner as Form).Skin;
			}
			
			form.Owner = owner;

			if (form.Owner == null)
			{
				form.StartPosition = FormStartPosition.CenterScreen;
			}
			else
			{
				form.StartPosition = FormStartPosition.CenterParent;
			}

			form.Text = text;
			form.Caption = caption;
			form.Icon = icon;
			form.Buttons = buttons;
			form.DefaultButton = defaultButton;
			form.Options = options;
			form.HelpFilePath = helpFilePath;
			form.HelpNavigator = helpNavigator;

			form.SetControlSizes();
			form.TopMost = true;
			form.ShowInTaskbar = false;

			return form.ShowDialog();
		}

		#endregion
	}
}
